﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Databases
{
    /// <summary>
    /// Object loads the DataAccessQueries.xml file and then the name of the query need
    /// can be passed to the appropriate method to retrieve the query
    /// </summary>
    class DataAccessQueriesReader
    {
        private static XmlDocument data;

        public DataAccessQueriesReader()
        {
            data = new XmlDocument();
            data.Load("DataAccessQueries.xml");
        }

        public string getSelect(string name)
        {
            return data.SelectSingleNode("/DataAccessSQL/Selects/Select[@name='" + name + "']/sql").InnerText;
        }

        public string getInsert(string name)
        {
            return data.SelectSingleNode("/DataAccessSQL/Inserts/Insert[@name='" + name + "']/sql").InnerText;
        }

        public string getDelete(string name)
        {
            return data.SelectSingleNode("/DataAccessSQL/Deletes/Delete[@name='" + name + "']/sql").InnerText;
        }

        public string getUpdate(string name)
        {
            return data.SelectSingleNode("/DataAccessSQL/Updates/Update[@name='" + name + "']/sql").InnerText;
        }
    }
}
